package com.west_traveler.ximalayafm;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.test.mock.MockApplication;
import android.util.Log;

import com.west_traveler.application.BaseApplication;
import com.west_traveler.entity.entity_editor.SpecialBean;
import com.west_traveler.entity.entity_editor.SpecialListenList;
import com.west_traveler.inteface.HttpService;
import com.west_traveler.recyclerview_adapter.SpecialRecyclerViewAdapter;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SpecialActivity extends AppCompatActivity implements Callback<SpecialListenList> {

    private RecyclerView recyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_special);

        initView();

        aboutData();
    }

    private void aboutData() {

        Intent intent = getIntent();
        int id = intent.getIntExtra("ID", 816);
        BaseApplication application = (BaseApplication) getApplication();
        HttpService service = application.getService();
        service.getSpecialList(id).enqueue(this);

    }

    private void initView() {
        recyclerView = (RecyclerView) findViewById(R.id.rv_special_id);

    }


    @Override
    public void onResponse(Call<SpecialListenList> call, Response<SpecialListenList> response) {

        SpecialRecyclerViewAdapter adapter = new SpecialRecyclerViewAdapter(this, response.body());
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void onFailure(Call<SpecialListenList> call, Throwable t) {

    }
}
